package com.yztc.ui.cook;
import android.util.Log;

import com.yztc.bean.cook.CateGoryListBean;
import com.yztc.bean.cook.CategoryBean;
import com.yztc.bean.cook.CookMainBean;
import com.yztc.bean.cook.CookerListBean;
import com.yztc.bean.cook.ListFocusBean;
import com.yztc.bean.cook.NewFoodBean;
import com.yztc.bean.cook.NewFoodTypeBean;
import com.yztc.ui.cook.jiekou.CookOnloadListener1;
import com.yztc.ui.cook.jiekou.CookOnloadListener2;

import java.util.List;


/**
 * Created by Administrator on 2016/10/8.
 */

public class CookPresenter implements CookConstract.Presenter {
        private CookConstract.View view;
        private CookConstract.Modle modle;
        public CookPresenter(CookConstract.View view){
            this.view=view;
            modle=new CookModle();
        }
        @Override
        public void getData() {
            modle.getData(CookUrlConfig.BASE_URL, new CookOnloadListener1() {
                @Override
                public void onSuccess(CookMainBean cookMainBean) {
                    final List<CateGoryListBean> listCategoty=cookMainBean.getCategory().getList();
                    final List<ListFocusBean> listFocusBeanList=cookMainBean.getListFocus();
                    final List<CookerListBean> listCooker=cookMainBean.getChef().getList();
                    view.onGetDataSuccess(listCategoty,listFocusBeanList,listCooker);
                    Log.i("wx","-------listCategoty-------"+listCategoty.size());
                    Log.i("wx","-------listFocusBeanList-------"+listFocusBeanList.size());
                    Log.i("wx","-------listCooker-------"+listCooker.size());

                }

                @Override
                public void onFailure(Throwable e) {
                    view.onGetDataFail(e);
                }
            });
        }

        @Override
        public void getNewFoodData() {
            modle.getNewFoodData(CookUrlConfig.BASE_URL,new CookOnloadListener2() {
                @Override
                public void onSuccess(NewFoodBean newFoodBean) {
                    view.onGetNewFoodDataSuccess(newFoodBean.getList());
                    Log.i("wx","--------------"+newFoodBean.getList().size());
                }

                @Override
                public void onFailure(Throwable e) {
                    view.onGetNewFoodDataFail(e);
                }
            });
        }
    }
